import {
  exportUrl,
  getModelingList,
} from "@/api/barcodeprint/mesProdBarcodeReprint";
import { getDict } from "@/api/common";

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", // 点击时返回的标识
    url: exportUrl,
    // auth: 'auth:operlog:export', // 权限字段
  },
  // {
  //   name: '新增',
  //   type: 'primary',
  //   icon: 'el-icon-circle-plus-outline',
  //   handleName: 'add', //点击时返回的标识
  // },
  // {
  //   name: '删除',
  //   type: 'danger',
  //   icon: 'el-icon-delete',
  //   handleName: 'deleteBatch', //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
];
// 行末按钮配置
export const rowConfig = [
  // {
  //   name: '详情',
  //   type: 'info',
  //   class: 'row-btn-info',
  //   handleName: 'detail', //点击时返回的标识
  // },
  {
    name: $i18n.t("mesCapacityCodeReprint.examine"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "examine",
  },
];
// 搜索条件配置
export const searchConfig = {
  data() {
    const _this = this;
    return {
      searchConfig: {
        inline: true,
        formDesc: {
          orderCode: {
            type: "input",
            label: _this.$i18n.t("mesCapacityCodeReprint.orderCode"),
          },
          prodCode: {
            type: "input",
            label: _this.$i18n.t("mesCapacityCodeReprint.prodCode"),
          },
          prodName: {
            type: "input",
            label: _this.$i18n.t("mesCapacityCodeReprint.prodName"),
          },
          planBeginDate: {
            type: "daterange",
            label: _this.$i18n.t("mesCapacityCodeReprint.planBeginDate"),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planBeginDateMin", "planBeginDateMax"],
            },
          },
          workshopCode: {
            type: "select",
            label: _this.$i18n.t("common.workshopName"),
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: _this.$store.getters.factoryCode,
                level: 4,
              };
              const list = await getModelingList(params);
              return list.data.result;
            },
          },
          lineCode: {
            type: "select",
            label: _this.$i18n.t("common.lineName"),
            disabled: (data) => {
              return data.workshopCode ? false : true;
            },
            optionsLinkageFields: ["workshopCode"],
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              if (data.workshopCode) {
                const params = {
                  modelingCode: data.workshopCode,
                  level: 5,
                };
                const list = await getModelingList(params);
                return list.data.result;
              } else {
                return [];
              }
            },
          },
          status: {
            type: "select",
            label: _this.$i18n.t("common.status"),
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getDict("mes_barcode_reprint_status");
              return list.data.result;
            },
          },
          isPrint: {
            type: "select",
            label: _this.$i18n.t("mesCapacityCodeReprint.isPrint"),
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getDict("yes_or_not");
              return list.data.result;
            },
          },
          createTime: {
            type: "daterange",
            label: _this.$i18n.t("mesCapacityCodeReprint.createTime"),
            attrs: {
              valueFormat: "yyyy-MM-dd 00:00:00",
              searchArrKey: ["createTimeMin", "createTimeMax"],
            },
          },
        },
      },
    };
  },
};
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    orderCode: {
      type: "input",
      label: $i18n.t("mesCapacityCodeReprint.orderCode"),
      layout: 12,
      required: false,
      disabled: true,
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesCapacityCodeReprint.prodCode"),
      layout: 12,
      required: false,
      disabled: true,
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesCapacityCodeReprint.prodName"),
      layout: 12,
      required: false,
      disabled: true,
    },
    planBeginDate: {
      type: "date",
      label: $i18n.t("mesCapacityCodeReprint.planBeginDate"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
      disabled: true,
    },
    workshopName: {
      type: "input",
      label: $i18n.t("common.workshopName"),
      layout: 12,
      required: false,
      disabled: true,
    },
    lineName: {
      type: "input",
      label: $i18n.t("common.lineName"),
      layout: 12,
      required: false,
      disabled: true,
    },
    startBarcode: {
      type: "input",
      label: $i18n.t("mesCapacityCodeReprint.startBarcode"),
      layout: 12,
      required: false,
      disabled: true,
    },
    endBarcode: {
      type: "input",
      label: $i18n.t("mesCapacityCodeReprint.endBarcode"),
      layout: 12,
      required: false,
      disabled: true,
    },
    printTemp: {
      type: "input",
      label: $i18n.t("mesCapacityCodeReprint.printTemp"),
      layout: 12,
      required: false,
      disabled: true,
    },
    examineContent: {
      type: "textarea",
      label: $i18n.t("mesCapacityCodeReprint.examineContent"),
      layout: 24,
      disabled: false,
      required: true,
    },
  },
};
